package ad_exercise_2.model;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

/**
 * Don't use this class! It is highly experimental and conceptually strange to say the least!
 * 
 * @author Erik
 * 
 * @param <E>
 */
public class HashMapSet<E> extends HashMap<E, E> {
	private static final long	serialVersionUID	= 7597860405030000280L;
	
	public boolean add(E e) {
		E existing = get(e);
		if (existing != null)
			return false;
		put(e, e);
		return true;
	}
	
	public E addAndReturn(E e) {
		E existing = get(e);
		if (existing != null)
			return existing;
		put(e, e);
		return e;
	}
	
	public boolean addAll(Collection<? extends E> c) {
		boolean result = false;
		for (E e : c)
			if (add(e)) {
				result = true;
			}
		
		return result;
	}
	
	public boolean contains(Object o) {
		return get(o) != null;
	}
	
	public boolean containsAll(Collection<?> c) {
		for (Object o : c) {
			if (get(o) == null)
				return false;
		}
		return true;
	}
	
	public Iterator<E> iterator() {
		return values().iterator();
	}
	
	public boolean removeAll(Collection<?> c) {
		// TODO Auto-generated method stub
		return false;
	}
	
	public boolean retainAll(Collection<?> c) {
		// TODO Auto-generated method stub
		return false;
	}
	
	public Object[] toArray() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public <T> T[] toArray(T[] a) {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public E remove(Object o) {
		// TODO
		E t = super.remove(o);
		return t;
	}
}
